package com.stars.questions.commonQuestion.publish.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.stars.base.entity.UserSelectDTO;
import com.stars.module.user.entity.StarOrgUser;
import com.stars.questions.commonQuestion.publish.entity.CommonReplyItem;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommonReplyItemMapper extends BaseMapper<CommonReplyItem> {
    @Select("SELECT \n" +
            "    r.id,\n" +
            "    MAX(CASE WHEN i.question = '您对自治区整治形式主义为基层减负政策措施的实施成效如何评价？' THEN i.answertext END) AS q1,\n" +
            "    MAX(CASE WHEN i.question = '您对身边的党员干部树立和践行正确政绩观，不搞“政绩工程”“形象工程”“面子工程”，把精力用在服务群众，解决实际问题上的总体情况如何评价？' THEN i.answertext END) AS q2,\n" +
            "    MAX(CASE WHEN i.question = '您对党政机关事业单位精简文件会议数量，提升文件质量、会议效率的成效如何评价？' THEN i.answertext END) AS q3,\n" +
            "    MAX(CASE WHEN i.question = '您对党政机关事业单位严控面向基层的督查检查数量，优化方式方法的成效如何评价？' THEN i.answertext END) AS q4,\n" +
            "    MAX(CASE WHEN i.question = '您对党政机关事业单位解决调研集中扎堆、只调不研、干扰基层正常工作等问题的成效如何评价？' THEN i.answertext END) AS q5,\n" +
            "    MAX(CASE WHEN i.question = '您对党政机关事业单位纠治滥用微信群、钉钉群、APP打卡接龙、考核排名等问题的成效如何评价？' THEN i.answertext END) AS q6,\n" +
            "    MAX(CASE WHEN i.question = '您对乡村振兴中因地制宜、实事求是，不搞简单“一刀切”，防止“穷折腾”、搞“花架子”的成效如何评价？' THEN i.answertext END) AS q7,\n" +
            "    MAX(CASE WHEN i.question = '您对严格规范涉企行政检查，切实为企业减负的成效如何评价？' THEN i.answertext END) AS q8,\n" +
            "    MAX(CASE WHEN i.question = '您对纠治基层公务政务活动中过度使用短视频、电子演示文稿等加重基层负担行为的成效如何评价？' THEN i.answertext END) AS q9,\n" +
            "    MAX(CASE WHEN i.question = '您对规范社会事务进校园，减轻教师非教育教学任务负担，确保正常教学秩序的成效如何评价？' THEN i.answertext END) AS q10,\n" +
            "    MAX(CASE WHEN i.question = '您对清理规范过多过滥、测评体系繁杂的创建示范和达标活动的成效如何评价？' THEN i.answertext END) AS q11,\n" +
            "    MAX(CASE WHEN i.question = '您对党政机关事业单位落实健全规范管理制度，严控借调干部的成效如何评价？' THEN i.answertext END) AS q12,\n" +
            "    MAX(CASE WHEN i.question = '您对党政机关事业单位清理规范缺乏实效、浪费资金、名不符实、违反规定的节庆、论坛、展会的成效如何评价？' THEN i.answertext END) AS q13,\n" +
            "    MAX(CASE WHEN i.question = '您对党政机关事业单位完善考核办法，优化考核体系指标方式，从考“材料”、查“痕迹”转变为考成效、看“潜绩”，使干部将更多精力用到抓落实上的成效如何评价？' THEN i.answertext END) AS q14,\n" +
            "    MAX(CASE WHEN i.question = '您对清理村级组织“滥挂牌”问题（指牌子数量多、种类多、形式多、虚名多，增加基层负担、影响服务效率）的成效如何评价？' THEN i.answertext END) AS q15,\n" +
            "    MAX(CASE WHEN i.question = '您对纠治基层多头重复填表格、报数据、交材料的成效如何评价？' THEN i.answertext END) AS q16,\n" +
            "    MAX(CASE WHEN i.question = '您对规范明晰基层权责事项的实施情况如何评价？' THEN i.answertext END) AS q17,\n" +
            "    MAX(CASE WHEN i.question = '您对落实“三个区分开来”，防止问责泛化简单化的实施情况如何评价？' THEN i.answertext END) AS q18,\n" +
            "    MAX(CASE WHEN i.question = '您对关爱基层干部，带薪休假等政策措施的实施情况如何评价？' THEN i.answertext END) AS q19,\n" +
            "    MAX(CASE WHEN i.question = '您认为形式主义加重基层负担问题严重的领域主要是？' THEN REPLACE(i.answertext,',','、') END) AS q20,\n" +
            "    MAX(CASE WHEN i.question = '您对解决身边的形式主义突出问题，切实减轻基层无谓的负担是否充满信心？' THEN i.answertext END) AS q21,\n" +
            "    MAX(CASE WHEN i.question = '您觉得当前身边突出的形式主义做法加重基层负担的问题有哪些？' THEN REPLACE(i.answertext,'\\n',' ') END) AS q22,\n" +
            "    MAX(CASE WHEN i.question = '您对下一步整治形式主义为基层减负工作的建议是什么？' THEN REPLACE(i.answertext,'\\n',' ') END) AS q23,\n" +
            "    MAX(CASE WHEN i.question = '您所在行政区?' THEN i.answertext END) AS q24,\n" +
            "    MAX(CASE WHEN i.question = '您的职业?' THEN i.answertext END) AS q25,r.ip_location AS location,r.createdate\n" +
            "FROM question_common_reply_item i\n" +
            "JOIN question_common_reply r ON i.fid = r.id\n" +
//            "WHERE  r.CONFIGID='01J29BEGYKKAZ7H2N4W50ENQHZ'  AND r.BT='2025年减负@我来评' AND r.CREATEDATE >='2025-04-01' \n" +
            "WHERE  r.CONFIGID='01J29BEGYKKAZ7H2N4W50ENQHZ'  \n" +
            "GROUP BY r.id\n" +
            "ORDER BY r.id")
    List<CommonReplyItem> loadQuestionListByConfigId(CommonReplyItem item);
}
